home *** CD-ROM | disk | FTP | other *** search
- # Jedi Knight Cog Script
- #
- # FORCE_PULL.COG
- #
- # FORCEPOWER Script - Force Pull
- # Basic Power
- # Bin 38
- #
- # [YB]
- #
- # (C) 1997 LucasArts Entertainment Co. All Rights Reserved
-
-
- symbols
-
- template powerup local
-
- int player local
- int victim local
- int potential local
- int throwThing local
-
- flex cost=20.0 local
- flex targetcost=5 local
- flex targetcount=0 local
- int rank local
- flex mana local
- flex dot local
- flex maxDot local
-
- int type local
- int retval=0 local
-
- sound pullSound=ForcePull01.WAV local
-
- int inbubble=0 local
-
- message startup
- message activated
- message deactivated
- message pulse
- message newplayer
- message killed
- message deselected
- message selected
- message enterbubble
- message exitbubble
-
- end
-
- # ========================================================================================
-
- code
-
- startup:
- player = GetLocalPlayerThing();
- inbubble = 0;
-
- Return;
-
- # ........................................................................................
-
- activated:
- if(inbubble) Return;
-
- // Cannot use power if blinded
- if(GetActorFlags(player) & 0x800) Return;
-
- if(IsInvActivated(player, 38)) Return;
-
- mana = GetInv(player, 14);
- rank = GetInv(player, 38);
-
- if(mana >= cost || GetInv(player, 14) >= GetInv(player, 69))
- {
- victim = -1;
- SetInvActivated(player, 38, 1);
- SetPulse(0.33);
- SetBinWait(player, 38, 1.0);
- }
- Return;
-
- # ........................................................................................
-
- pulse:
- targetCount = targetCount + 1;
- if(targetCount == 3)
- {
- if(GetInv(player, 64) != 1) ChangeInv(player, 14, -targetCost);
- targetCount = 0;
- }
-
- // Check all things for our victim.
- victim = -1;
- maxDot = 0;
-
- // Search for all players and actors.
- potential = FirstThingInView(player, 20 + 15 * rank, 5.5, 0x404);
- while(potential != -1)
- {
- if(
- HasLOS(player, potential) &&
- (potential != player) &&
- (VectorDist(GetThingPos(player), GetThingPos(potential)) <= (0.5 + rank / 2)) &&
- !(GetThingFlags(potential) & 0x200) &&
- !(GetActorFlags(potential) & 0x100) &&
- !((jkGetFlags(potential) & 0x20) && !IsInvActivated(player, 23)) &&
- (jkGetBubbleDistance(potential) > 1.0)
- )
- {
- dot = ThingViewDot(player, potential);
- if(dot > maxDot)
- {
- victim = potential;
- maxDot = dot;
- }
- }
- potential = NextThingInView();
- }
-
- // If we have a victim...
- if(victim != -1)
- {
- jkSetTargetColors(18, 19, 20);
- jkSetTarget(victim);
- }
- else
- {
- jkEndTarget();
- }
-
- Return;
-
- # ........................................................................................
-
- deactivated:
-
- if((victim == -1) || (GetThingHealth(player) <= 0) || inbubble)
- {
- call stop_power;
- Return;
- }
-
- SetPulse(0);
- jkEndTarget();
-
- mana = GetInv(player, 14);
-
- if(mana >= cost || GetInv(player, 14) >= GetInv(player, 69))
- {
- if(HasLOS(player, victim)) // check that we still have a LOS on it...
- {
- PlayMode(player, 24);
- PlaySoundThing(pullSound, player, 1.0, -1, -1, 0x80);
- if(GetInv(player, 64) != 1) ChangeInv(player, 14, -cost);
-
- // Send a "force disturbance"...
- if(!IsMulti())
- SendMessageExRadius(GetThingPos(player), cost, 0x4, splash, 38, 0, 0, 0);
-
- SetBinWait(player, 38, 0.6);
-
- throwThing = -1;
- type = GetThingType(victim);
- if(type == 2) // ACTOR
- {
- DetachThing(victim);
- ApplyForce(victim, VectorScale(VectorNorm(VectorSub(GetThingPos(victim),GetThingPos(player))), 120 * rank));
- SetInvActivated(player, 38, 0);
- Return;
- }
- else
- if(type == 10) // OTHER PLAYER
- {
- if(!(GetThingFlags(victim) & 0x200))
- retval = SkillTarget(victim, player, 38, rank);
- SetInvActivated(player, 38, 0);
- victim = -1;
- Return;
- }
- }
- }
-
- SetInvActivated(player, 38, 0);
- Return;
-
- # ........................................................................................
-
- selected:
- jkPrintUNIString(player, 38);
- Return;
-
- # ........................................................................................
-
- deselected:
- call stop_power;
- Return;
-
- # ........................................................................................
-
- killed:
- if(GetSenderRef() != player) Return;
-
- newplayer:
- call stop_power;
- Return;
-
- # ........................................................................................
-
- enterbubble:
- inbubble = 1;
- call stop_power;
- Return;
-
- # ........................................................................................
-
- exitbubble:
- inbubble = 0;
- Return;
-
- # ........................................................................................
-
- stop_power:
- SetPulse(0);
- SetInvActivated(player, 38, 0);
- victim = -1;
- jkEndTarget();
-
- Return;
-
- end
-
-
-